import { reqGetcarousel, getHomePhoneData, getHomeTVdata, getHomePartsData} from "@/api"
// 全部商品分类
const state={
    carouselList:{},
    homePhone:[],
    homeTV: [],
    homeParts:[],
}
const mutations ={
    GETCAROUSEL(state,carouselList){
        state.carouselList=carouselList
    },
    GETHOMEPHONEDATA(state,val){
        state.homePhone = val
    },
    GETHOMETVDATA(state,val){
        state.homeTV = val
    },
    GETHOMEPARTSDATA(state, val) {
        state.homeParts = val
    }
}
const actions ={
    // 轮播图数据
    async getCarousel({commit}){
        let result= await reqGetcarousel()
        if(result.code=== '001'){
            commit("GETCAROUSEL",result.carousel)
        }
    },
    // 首页手机数据
    async getHomePhoneData({commit}){
        let result = await getHomePhoneData()
        commit("GETHOMEPHONEDATA",result.Product)
    },
    // 首页家电数据
    async getHomeTVdata({commit}){
        let result = await getHomeTVdata()
        commit("GETHOMETVDATA",result.Product)
    },
    // 首页配件数据
    async getHomePartsdata({ commit }) {
        // console.log(888);
         let result = await getHomePartsData();
         console.log(result)
         commit("GETHOMEPARTSDATA",result.Product)
    }
}
const getters={}
export default{
    state,
    mutations,
    actions,
    getters
}